import http from '@/http'

// 用户列表
export const userListAPI = (params: IUserListParams): RES<IUserListModel> =>
  http.get("/admin/list", { params })

// 更新账号状态
export const updateStatusAPI = (id: number, status: number): RES<number> =>
  http.post(`/admin/updateStatus/${id}?status=${status}`)

// 注册账号
export const registerAPI = (params: IUserModel): RES<IUserModel> =>
  http.post("/admin/register", params)

// 获取指定用户信息
export const getUserIdAPI = (id: number): RES<IUserModel> =>
  http.get(`/admin/${id}`)

// 修改指定用户信息
export const updateUserAPI = (params: IUserModel): RES<number> =>
  http.post(`/admin/update/${params.id}`, params)

// 获取所有角色
export const roleListAllAPI = (): RES<IRole[]> => http.get("/role/listAll")

// 获取指定用户的角色
export const getRoleIdAPI = (adminId: number): RES<IRole[]> =>
  http.get(`/admin/role/${adminId}`)

// 给用户分配角色
export const roleUpdateAPI = (id: number, ids: number[]): RES<number> =>
  http.post(`/admin/role/update?adminId=${id}&roleIds=${ids}`) 